//
//  RTAlbumInfoController.m
//  RBToyAPI
//
//  Created by baxiang on 2018/2/1.
//  Copyright © 2018年 roobo. All rights reserved.
//

#import "RTAlbumInfoController.h"
#import "RTImageInfoCell.h"

@interface RTAlbumInfoController ()
@property(nonatomic,strong) NSMutableArray *dataArray;
@end

@implementation RTAlbumInfoController

- (void)viewDidLoad {
    [super viewDidLoad];
     self.dataArray = [NSMutableArray new];
    [self.tableView registerClass:[RTImageInfoCell class] forCellReuseIdentifier:NSStringFromClass([RTImageInfoCell class])];
    @weakify(self);
    [RBPlayerApi getResourceList:_albumModel.aID page:1 count:20 block:^(RBResourceList * _Nullable list, NSError * _Nullable error) {
        @strongify(self);
        if (list.list.count) {
            [self.dataArray addObjectsFromArray:list.list];
            [self.tableView reloadData];
        }
    }];
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

#pragma mark - Table view data source



- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.dataArray.count;
}

-(CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 55;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    RTImageInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([RTImageInfoCell class]) forIndexPath:indexPath];
    RBResourceModel *resourceModel = [self.dataArray objectAtIndex:indexPath.row];
    [cell.contentImgView yy_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",_albumModel.thumb]] placeholder:nil];
    cell.contentlab.text = resourceModel.name;
    return cell;
}


/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
